package cn.zmit.kuxi.activity;

import android.os.Bundle;
import android.widget.TextView;
import cn.zmit.kuxi.R;
import cn.zmit.kuxi.request.RequestTask;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.xdroid.functions.request.JsonData;
import com.xdroid.request.extension.XDroidRequest;
import com.xdroid.request.extension.config.DataType;
import com.xdroid.request.extension.impl.OnRequestListenerAdapter;

/** * @author chenxu @parameter * @return */
public class HelpDetailsActivity extends BaseActivity {
	@ViewInject(R.id.tv_title)
	private TextView tv_title;
	@ViewInject(R.id.tv_content)
	private TextView tv_content;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		String id = getTextFromBundle("id");
		if(id.equals("1")){
			setTitleView("关于我们", true);
		}else if(id.equals("2")){
			setTitleView("服务协议", true);
		}else if(id.equals("3")){
			setTitleView("帮住中心", true);
		}
		setContentView(R.layout.actity_help_details);
		ViewUtils.inject(this);
		
		
		// ToastUtils.show(this, id);
		RequestTask.getInstance().getHelpDetails(this, id,
				new onRequestListener());
	}

	private class onRequestListener extends OnRequestListenerAdapter<Object> {
		@Override
		public void onDone(XDroidRequest<?> request, String response,
				DataType dataType) {
			// TODO Auto-generated method stub
			super.onDone(request, response, dataType);
			JsonData jsonData = JsonData.create(response);
			JsonData data = jsonData.optJson("help_info");
			if (data != null && data.length() > 0) {

				String title = data.optString("title");
				String content = data.optString("content");
				//tv_title.setText(title);
				tv_content.setText(content);
			}
		}
	}
}
